package org.dromara.system.business.applicationManage.controller;

import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Param;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.web.page.TableDataInfo;
import org.dromara.system.business.applicationManage.domain.dto.AppManageParamDTO;
import org.dromara.system.business.applicationManage.domain.vo.AppManageVO;
import org.dromara.system.business.applicationManage.service.ApplicationManageService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 应用管理
 * @Author: CHS
 * @CreateTime: 2025-02-08  11:15
 */
@RestController
@RequestMapping("/appManage")
public class AppManageController {
    @Resource
    private ApplicationManageService applicationManageService;

    /**
     * 应用新增（上架）
     * @param: appManageParamDTO 新增参数
     * @author CHS
     * @date: 2025/2/10 11:02
     */
    @PostMapping("/appAdd")
    public R appAdd(@RequestBody AppManageParamDTO appManageParamDTO){
        return R.ok(applicationManageService.applicationAdd(appManageParamDTO));
    }

    /**
     * 应用查询
     * @param: null
     * @author CHS
     * @date: 2025/2/10 11:02
     */
    public TableDataInfo appQuery(@RequestBody AppManageParamDTO appManageParamDTO){
        return TableDataInfo.build(applicationManageService.appQuery(appManageParamDTO));
    }

    /**
     * 应用编辑
     * @param: null
     * @author CHS
     * @date: 2025/2/10 11:02
     */
    public R appUpdate(@RequestBody AppManageParamDTO appManageParamDTO){
        return R.ok(applicationManageService.appUpdate(appManageParamDTO));
    }

    /**
     * 应用详情
     * @param: null
     * @author CHS
     * @date: 2025/2/10 11:02
     */
    @GetMapping("/appDetail")
    public R<AppManageVO> appDetail(@Param("id") Long id){
        return R.ok(applicationManageService.appDetail(id));
    }

    /**
     * 应用删除
     * @param: null
     * @author CHS
     * @date: 2025/2/10 11:02
     */
    @GetMapping("/appDelete")
    public R appDelete(@Param("id") Long id){
        return R.ok(applicationManageService.appDelete(id));
    }
}
